<!DOCTYPE html>
<html lang="cn">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    class User {
        constructor(name) {
            this._name = name;
            this.check()
        }
        set name(value) {
            if (value.length < 5) {
                throw new Error('长度小于5')
            }
            this._name = value;
        }
        get name() {
            return this._name;
        }
        check() {
            if (this._name.length < 5) {
                throw new Error('长度小于5')
            }
        }

    }
    const user = new User('ydddyg');
    // user.name = 'yyg'
    // console.log(user)
    console.log(user.name)

</script>